package com.pur.zsms.common.util;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

public class FileUtill {

	public static void saveFileFromInputStream(InputStream stream, String path, String filename) throws IOException {
		FileOutputStream fs = new FileOutputStream(path + "/" + filename);
		byte[] buffer = new byte[1024 * 1024];
		int bytesum = 0;
		int byteread = 0;
		while ((byteread = stream.read(buffer)) != -1) {
			bytesum += byteread;
			fs.write(buffer, 0, byteread);
			fs.flush();
		}
		fs.close();
		stream.close();
	}

	public static void saveFileFromInputStreamSeparator(InputStream stream, String path, String filename) throws IOException {
		FileOutputStream fs = new FileOutputStream(path + File.separator + filename);
		byte[] buffer = new byte[1024 * 1024];
		int bytesum = 0;
		int byteread = 0;
		while ((byteread = stream.read(buffer)) != -1) {
			bytesum += byteread;
			fs.write(buffer, 0, byteread);
			fs.flush();
		}
		fs.close();
		stream.close();
	}

	// 创建字母map excel 对应列

	public static Map<Integer, String> getLetterMap() {
		Map<Integer, String> a = new HashMap<Integer, String>();
		a.put(0, "A");
		a.put(1, "B");
		a.put(2, "C");
		a.put(3, "D");
		a.put(4, "E");
		a.put(5, "F");
		a.put(6, "G");
		a.put(7, "H");
		a.put(8, "I");
		a.put(9, "J");
		a.put(10, "K");
		a.put(11, "L");
		a.put(12, "M");
		a.put(13, "N");
		a.put(14, "O");
		a.put(15, "P");
		a.put(16, "Q");
		a.put(17, "R");
		a.put(18, "S");
		a.put(19, "T");
		a.put(20, "U");
		a.put(21, "V");
		a.put(22, "W");
		a.put(23, "X");
		a.put(24, "Y");
		a.put(25, "Z");

		return a;

	}

}
